<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>
    var arr = [7,6,5,4,3];
    console.log(arr);

    // 两两比较，大的放后面
    // 0-1, 1-2, 2-3, 3-4   0~length-1-0
    // 0-1, 1-2, 2-3        0~length-1-1
    // 0-1, 1-2             0~length-1-2
    // 0-1                  0~length-1-3

    for(var i=0;i<arr.length-1;i++){
        for(var j=0;j<arr.length-1-i;j++){
            if(arr[j] > arr[j+1]){
                var x = arr[j];
                arr[j] = arr[j+1]
                arr[j+1] = x;
            }
        }
    }



    console.log(arr);
</script>
</html>